package com.rtx.wms.customer.ris.so;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.rtx.wms.customer.ris.CallRisAPI;
import com.rtx.wms.std.common.bean.WmsConstant;
import com.rtx.wms.std.so.bean.ApiOrdersfinish;

/**
 * 调用 RIS-WMS
 * 核实结算ASN
 * @author Administrator
 *
 */
@Component
public class CallRisOrderFinish extends CallRisAPI{
	
	Logger log = LoggerFactory.getLogger(this.getClass());

	//riswms 返回响应
	//	{
	//	    "returnCode": "200",
	//	    "returnMgr": "SUCCESS",
	//	    "page": null,
	//	    "list": null,
	//	    "bean": null,
	//	    "token": null,
	//	    "userLanguage": null
	//	}
	@Override
	protected void resolveResonse(String response, Object data) {
		ApiOrdersfinish finish = (ApiOrdersfinish) data;
		try {
			JSONObject res = JSON.parseObject(response,JSONObject.class);
			String code = res.getString("code");
			if(!"200".equals(code)) {
				finish.setCallshipediflag((WmsConstant.FAIL_FLAG));
				finish.setCallshipmsg(res.getString("returnMgr"));
			}else {
				finish.setCallshipediflag(WmsConstant.SUCCESS_FLAG);
				finish.setCallshipmsg(res.getString("returnMgr"));
			}
		} catch (Exception e) {
			log.error("",e);
			finish.setCallshipediflag(WmsConstant.FAIL_FLAG);
			finish.setCallshipmsg(e.getMessage());
		}
		
	}
	

}
